import Vue from 'vue'
import Router from 'vue-router'
import Login from "../components/Login";
import Register from "../components/Register";

Vue.use(Router)

export default new Router({
  // 除去锚点#
  mode: "history",
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('../components/Home'),
      redirect: "/index",
      children: [
        {
          path: '/index',
          name: 'AppIndex',
          component: () => import('../components/home/AppIndex'),
        },
      ]
    },
    {
      path: '/user_login',
      name: 'UserLogin',
      component: () => import('../components/UserLogin')
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('../components/Login')
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('../components/Register')
    },
    {
      path: '/system',
      name: 'System',
      component: () => import('../components/system/SystemIndex'),
      meta: {
        requireAuth: true
      },
      children: [
        {
          path: '/system/dashboard',
          name: 'Dashboard',
          component: () => import('../components/system/dashboard/DashboardIndex'),
          meta: {
            requireAuth: true
          }
        }
      ]
    },
    {
      path:'/customer',
      name:'Customer',
      component:()=>import('../components/customer/CustomerIndex'),
      meta:{
        requireAuth: true
      },
      children:[
        {
          path:'/customer/order_reserve',
          name:'OrderReserve',
          component:()=>import('../components/customer/reserve/OrderReserve'),
          meta:{
            requireAuth: true
          }
        },
        {
          path:'/customer/customer_order',
          name:'CustomerOrder',
          component:()=>import('../components/customer/reserve/CustomerOrder'),
          meta:{
            requireAuth: true
          }
        }
      ]
    }
  ]
})

export const createRouter = routes => new Router({
  // 除去锚点#
  mode: "history",
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('../components/Home'),
      redirect: "/index",
      children: [
        {
          path: '/index',
          name: 'AppIndex',
          component: () => import('../components/home/AppIndex'),
        },

      ]
    },
    {
      path: '/user_login',
      name: 'UserLogin',
      component: () => import('../components/UserLogin')
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('../components/Login')
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('../components/Register')
    },
    {
      path: '/system',
      name: 'System',
      component: () => import('../components/system/SystemIndex'),
      meta: {
        requireAuth: true
      },
      children: [
        {
          path: '/system/dashboard',
          name: 'Dashboard',
          component: () => import('../components/system/dashboard/DashboardIndex'),
          meta: {
            requireAuth: true
          }
        }
      ]
    },
    {
      path:'/customer',
      name:'Customer',
      component:()=>import('../components/customer/CustomerIndex'),
      meta:{
        requireAuth: true
      },
      children:[
        {
          path:'/customer/order_reserve',
          name:'OrderReserve',
          component:()=>import('../components/customer/reserve/OrderReserve'),
          meta:{
            requireAuth: true
          }
        },
        {
          path:'/customer/customer_order',
          name:'CustomerOrder',
          component:()=>import('../components/customer/reserve/CustomerOrder'),
          meta:{
            requireAuth: true
          }
        }
      ]
    }
  ]
})
